﻿using System;
using System.Diagnostics;

namespace Gmantis.Controls
{
    [DebuggerStepThrough]
    internal static class RangeAssert
    {
        // Methods
        public static void IsFalse(string paramName, bool condition)
        {
            if (condition)
            {
                throw new ArgumentException(paramName);
            }
        }

        public static void IsTrue(string paramName, bool condition)
        {
            if (!condition)
            {
                throw new ArgumentException(paramName);
            }
        }

        public static void NotEmpty(string value)
        {
            NotEmpty(null, value, false);
        }

        public static void NotEmpty<T>(T[] values)
        {
            NotEmpty<T>(values);
        }

        public static void NotEmpty(string value, bool trim)
        {
            NotEmpty(null, value, trim);
        }

        public static void NotEmpty(string paramName, string value)
        {
            NotEmpty(paramName, value, false);
        }

        public static void NotEmpty<T>(string paramName, T[] values)
        {
            if ((values != null) && (values.Length == 0))
            {
                throw new ArgumentException(paramName);
            }
        }

        public static void NotEmpty(string paramName, string value, bool trim)
        {
            if (value != null)
            {
                if (trim)
                {
                    NotEmpty(paramName, value.Trim(), false);
                }
                else if (value.Length == 0)
                {
                    throw new ArgumentException(paramName);
                }
            }
        }

        public static void NotNull(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException();
            }
        }

        public static void NotNull(string paramName, object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(paramName);
            }
        }
    }
}
